package cn.com.wangkai.wangkaisiji.utils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import cn.com.wangkai.wangkaisiji.bean.CartBean;
import cn.com.wangkai.wangkaisiji.bean.OrderBean;

/**
 * Created by Administrator on 2016/11/15.
 */
public class JSONParser {

    public static void typeOneOrThree(JSONArray jdata, int i) throws JSONException {
        //Log.e("", "不需要拆分的"+jdata.getJSONObject(i).getString("orderId")+"长度===="+gro.size());
        OrderBean b = new OrderBean();
        b.setPrice(jdata.getJSONObject(i).getString("price"));
        b.setOrderId(jdata.getJSONObject(i).getString("orderId"));
        b.setCompanyId(jdata.getJSONObject(i).getString("companyName"));
        b.setStatus(jdata.getJSONObject(i).getString("status"));
        b.setIsSingleCompany(true);
        b.setCreateTime(jdata.getJSONObject(i).getString("createTime"));
        b.setType(jdata.getJSONObject(i).getString("type"));
        b.setInvoiceStatus(jdata.getJSONObject(i).getString("invoiceStatus"));
        b.setCommentStatus(jdata.getJSONObject(i).getString("commentStatus"));
        b.setPayment(jdata.getJSONObject(i).getString("payment"));
        b.setName(jdata.getJSONObject(i).getJSONObject("vendorInfo").getString("shortName"));
        b.setPhone(jdata.getJSONObject(i).getJSONObject("vendorInfo").getString("phone"));


    }
    public static List<CartBean> parseOrderList(JSONArray jchild) throws JSONException {
        List<CartBean> cartbeans=new ArrayList<CartBean>();
        for (int a=0;a<jchild.length();a++){
            JSONObject obj=jchild.getJSONObject(a);
            CartBean ob=new CartBean();
            ob.setPrice(obj.getString("price"));
            ob.setNum(Integer.parseInt(obj.getString("num")));
            ob.setItemName(obj.getString("itemName"));
            ob.setPic(obj.getString("pic"));
            cartbeans.add(ob);
        }

    return cartbeans;
    }



}
